package com.zjj.algorithm.learning.atguigu.tree;

/**
 * @author zjj_admin
 * @date 2022/11/27 10:43
 */
public class ThreadedBinaryTreeDemo {

    public static void main(String[] args) {

        ThreadedTreeNode treeNode1 = new ThreadedTreeNode(1);
        ThreadedTreeNode treeNode2 = new ThreadedTreeNode(2);
        ThreadedTreeNode treeNode3 = new ThreadedTreeNode(3);
        ThreadedTreeNode treeNode4 = new ThreadedTreeNode(4);
        ThreadedTreeNode treeNode5 = new ThreadedTreeNode(5);
        ThreadedTreeNode treeNode6 = new ThreadedTreeNode(6);

        /**
         *                                 1
         *                           2           3
         *                       4      5      6
         */

        ThreadedBinaryTree threadedTree = new ThreadedBinaryTree();
        threadedTree.setRoot(treeNode1);

        treeNode1.setLeft(treeNode2);
        treeNode1.setRight(treeNode3);
        treeNode2.setLeft(treeNode4);
        treeNode2.setRight(treeNode5);
        treeNode3.setLeft(treeNode6);

        threadedTree.midThreadedNodes(treeNode1);
        System.out.println("threadedTree = " + threadedTree);
        TreeNode leftNode = treeNode5.getLeft();
        TreeNode rightNode = treeNode5.getRight();
        System.out.println("leftNode = " + leftNode);
        System.out.println("rightNode = " + rightNode);

        TreeNode root = threadedTree.getRoot();
        System.out.println("root = " + root);
        System.out.println("===========================");
        threadedTree.midOrder();

    }
}
